var app = getApp();

Page({
    data: {
        btn_disabled: !1,
        submitIsLoading: !1
    },
    onLoad: function(a) {
        var e = this;
        app.util.getUserInfo(function(a) {
            e.setData({
                userInfo: a
            });
        });
        var t = a.cardid;
        e.setData({
            cardId: t
        }), 0 < t && app.util.request({
            url: "entry/wxapp/GetCard",
            data: {
                m: "bbyscm_card",
                cardid: t
            },
            success: function(a) {
                0 == a.data.errno && e.setData({
                    card_info: a.data.data,
                    cardid: a.data.data.id,
                    video: a.data.data.video,
                    thumb: a.data.data.videothumb
                });
            }
        }), app.util.request({
            url: "entry/wxapp/VideoSetup",
            data: {
                m: "bbyscm_card"
            },
            success: function(a) {
                e.setData({
                    videosetup: a.data.data
                });
                var t = wx.createInnerAudioContext();
                t.autoplay = !0, t.src = a.data.data.audio;
            }
        });
    },
    formSubmit: function(a) {
        console.log("提交返回", a);
        var t = this;
        t.setData({
            btn_disabled: !0,
            submitIsLoading: !0
        }), JSON.stringify(a.detail.value);
        var e = a.detail.formId, o = t.data.cardid, n = a.detail.value.video;
        wx.showToast({
            title: "提交中...",
            icon: "loading",
            duration: 5e3
        }), app.util.request({
            url: "entry/wxapp/AppJieXi",
            data: {
                m: "bbyscm_card",
                form_id: e,
                cardid: o,
                video: n
            },
            method: "POST",
            success: function(a) {
                console.log("提交返回2", a), 0 == a.data.errno ? wx.showModal({
                    title: "提示",
                    content: "提交成功",
                    showCancel: !1,
                    success: function(a) {
                        wx.navigateBack();
                    }
                }) : wx.showModal({
                    title: "提示",
                    content: a.data.message,
                    showCancel: !1,
                    success: function(a) {
                        a.confirm;
                    }
                });
            },
            fail: function(a) {
                wx.showModal({
                    title: "提示",
                    content: a.data.message,
                    showCancel: !1,
                    success: function(a) {
                        a.confirm && t.setData({
                            btn_disabled: !1,
                            submitIsLoading: !1
                        });
                    }
                });
            },
            complete: function() {
                wx.hideToast();
            }
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {}
});